identityMode={
	
}
function Game(){
	evt=new Event('Game');
	evt.content=function(){
		ChooseCharacter();
		// PrepareGame();
		// GameStart();
		// GameDraw();
		// PhaseLoop();
	}
	gameLoop();
}
function ChooseCharacter(){
	var next=addEvent('ChooseCharacter');
	next.content=function(step){
		switch(step){
			case 0:
			var list=new Array();
			var list2=new Array();
			for(var i in config[config.mode].characters){
				var pack=eval(config[config.mode].characters[i]+"Character");
				for(var j in pack.characters){
					game.characters[j]=pack.characters[j];
					list.push(j);
					if(pack.characters[j][4]=='zhu') list2.push(j);
				}
				for(var j in pack.skills){
					game.skills[j]=pack.skills[j];
				}
				for(var j in pack.translate){
					ui.translate[j]=pack.translate[j];
				}
				for(var j in pack.api){
					api[j]=pack.api[j];
				}
			}
			list.sort(randomSort);
			openDialog('选择角色',[list,'character'])
			
			var choice=new Array();
			if(game.me.identity!='zhu'){
				var x=ai.chooseZhu(list,list2);
				removeItem(list,x);
				ui.setPlayer(game.zhu,x);
				for(var i=0;i<config[config.mode].choice[game.me.identity];i++){
					choice.push(list.shift());
				}
			}
			else{
				var j=config[config.mode].choice['zhu'];
				var i=0;
				while(j--){
					while(game.characters[list[i]][4]=='zhu') i++;
					choice.push(list.splice(i,1));
				}
				choice=choice.concat(list2);
			}
			var select=1;
			if(config[config.mode].double_character) select=2;
			openDialog('选择角色',[choice,'character'])
			ChooseButton(select,true);
			evt.list=list;
			break;

			case 1:
			closeDialog();
			if(evt.result.buttons.length==2)
				ui.setPlayer(game.me,evt.result.buttons[0].link,evt.result.buttons[1].link);
			else
				ui.setPlayer(game.me,evt.result.buttons[0].link);
			removeItem(evt.list,evt.result.buttons[0].link);
			for(var i in game.players){
				if(game.players[i]==game.zhu||game.players[i]==game.me) continue
				ui.setPlayer(game.players[i],ai.chooseCharacter(game.players[i].identity));
			}
			break;
			default:
			finish();
		}
	}
}